package com.itheima.test.UDP.multicast;

import java.io.IOException;
import java.net.*;

public class Client {//组播代码实现
    public static void main(String[] args) throws IOException {
        DatagramSocket socket = new DatagramSocket();
        String s ="Hello,组播";
        //组播地址:224.0.0.0~239.255.255.255(224.0.0.0~224.0.0.255为预留的组播地址)
        InetAddress address = InetAddress.getByName("224.0.1.0");//向组播地址发送数据
        DatagramPacket packet = new DatagramPacket(s.getBytes(),s.getBytes().length,address,10000);
        //码头发送数据
        socket.send(packet);
        //释放资源
        socket.close();
    }
}
